package com.miao
{
	import com.miao.controller.LoadConfigCommand;
	import com.miao.controller.PlayUrlCommand;
	import com.miao.controller.SourceCompleteCommand;
	import com.miao.controller.SourceLoadingCommand;
	import com.miao.controller.StartUpCommand;
	import com.miao.controller.WindowEventCommand;
	import com.miao.utils.Consts;
	
	import org.puremvc.as3.multicore.patterns.facade.Facade;
	
	public class ApplicationFacade extends Facade
	{
		public function ApplicationFacade(key:String)
		{
			super(key);
		}
		
		public static function getInstance(key:String):ApplicationFacade{
			if(!instanceMap[key]) instanceMap[key] = new ApplicationFacade(key);
			
			return instanceMap[key] as ApplicationFacade;
		}
		
		override protected function initializeController():void{
			super.initializeController();
			
			registerCommand(Consts.START_UP, StartUpCommand);
			registerCommand(Consts.LOAD_CONFIG, LoadConfigCommand);
			registerCommand(Consts.PLAY_URL, PlayUrlCommand);
			registerCommand(Consts.WINDOW_EVENT, WindowEventCommand);
			registerCommand(Consts.SOURCE_PROGRESS, SourceLoadingCommand);
			registerCommand(Consts.SOURCE_COMPLETE, SourceCompleteCommand);
		}
		
		public function startUp(app:StudyPlayer):void{
			sendNotification(Consts.START_UP, app);
		}
	}
}